#include <iostream>
#include <vector>
#include <unordered_map>

std::pair<int, int> GetSumIndex(std::vector<int> vec, int sum)
{
    std::pair<int, int> res;
    std::unordered_map<int, int> val_ind_map;
    for (int i = 0; i < vec.size(); ++i)
    {
        int left_val = vec.at(i);
        int right_val = sum - left_val;
        if (val_ind_map.find(right_val) == val_ind_map.end())
        {
            val_ind_map.insert(std::make_pair(left_val, i));
            continue;
        }
        res.first = val_ind_map[right_val];
        res.second = i;
        break;
    }
    return res;
}

int main(int argc, char **argv)
{
    std::vector<int> array{1, 2, 3, 5, 7, 9};
    auto res = GetSumIndex(array, 8);
    std::cout << "index1: " << res.first << std::endl;
    std::cout << "index2: " << res.second << std::endl;
    return 0;
}